from selenium.webdriver.common.by import By

from base.BasePage import BasePage


class WebIndexPage(BasePage):
    def __init__(self,driver):
        self.driver = driver


    # 进入登录界面(未登录状态，从首页进入登陆界面)
    def go_to_login(self):
        self.find_ele((By.LINK_TEXT,"登录")).click()


    # 进入首页(登录后，从个人界面进入首页)
    def go_to_index(self):
        self.find_ele((By.LINK_TEXT,"首页")).click()

    # 搜索商品
    def search_goods(self,good_name):
        #1.输入商品名称
        self.input_text(self.find_ele((By.ID,"q")),good_name)
        # 2.点击搜索
        self.find_ele((By.XPTH,f'//button[normalize-space(text())="{good_name}"]')).click()


